part of '../../repository.dart';

class _WebPurchasedItemDtoFactory {
  const _WebPurchasedItemDtoFactory._internal();

  static const _instance = _WebPurchasedItemDtoFactory._internal();

  factory _WebPurchasedItemDtoFactory() {
    return _instance;
  }

  _WebPurchasedItemDto fromJson(Map<String, dynamic> json) {
    final type = json[_kWebPurchasedItemTypeKey] as String;

    switch (type) {
      case _kWebPurchasedSubscriptionTypeValue:
        return _WebPurchasedSubscriptionDto.fromJson(json);
      case _kWebOneTimePurchasedItemTypeValue:
        return _WebOneTimePurchasedItemDto.fromJson(json);
      default:
        throw UnimplementedError();
    }
  }
}
